{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "c23f474d",
   "metadata": {},
   "source": [
    "## 本周学习内容\n",
    "\n",
    "### 1.Head First Python P4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "6ceb1842",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "9\n",
      "现在是秒/时间为奇数\n"
     ]
    }
   ],
   "source": [
    "import datetime\n",
    "# 本项目用到了时间模块\n",
    "# print(datetime.datetime.today().microsecond)\n",
    "\n",
    "# odds 是一个变量，后面可以直接使用\n",
    "odds = [  1, 3,  5,  7,  9, 11,13,15,17,19,\n",
    "             21,23,25,27,29,31,33,35,37,39,\n",
    "             41,43,45,47,49,51,53,55,57,59]\n",
    "\n",
    "# right_this_minute 是一个变量，是随着当前时间分钟数不断变化的一个值\n",
    "right_this_minute = datetime.datetime.today().second\n",
    "\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(right_this_minute)\n",
    "    print(\"现在是秒/时间为奇数\")\n",
    "else:\n",
    "    print(right_this_minute)\n",
    "    print(\"现在秒/时间为偶数\")\n",
    "\n",
    "# print(datetime.datetime.today().microsecond)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "cad17a3e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "319527\n",
      "This minute seems a little odd.\n",
      "319527\n"
     ]
    }
   ],
   "source": [
    "import datetime\n",
    "\n",
    "print(datetime.datetime.today().microsecond)\n",
    "\n",
    "odds = [  1, 3,  5,  7,  9, 11,13,15,17,19,\n",
    "             21,23,25,27,29,31,33,35,37,39,\n",
    "             41,43,45,47,49,51,53,55,57,59]\n",
    "\n",
    "right_this_minute = datetime.datetime.today().minute\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(\"This minute seems a little odd.\")\n",
    "else:\n",
    "    print(\"Not an odd minute.\")\n",
    "\n",
    "print(datetime.datetime.today().microsecond)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "14b8dd9c",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "23edee94",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime().tm_wday"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "f4159f26",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "今天有python课，时间为：下午2：30-4：50\n"
     ]
    }
   ],
   "source": [
    "# tm_wday:  0-6  0 是星期一\n",
    "今天 = time.localtime().tm_wday\n",
    "\n",
    "if 今天 == 1:\n",
    "    print(\"今天有python课，时间为：下午2：30-4：50\")\n",
    "else:\n",
    "    print(\"今天没有python课，哈哈哈哈哈哈，太开心了！\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "1505564f",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "f1707346",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "16"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime().tm_hour  # 是不是在 14到16之间   如果是14 再看tm_minute  是不是在0-30  如果是16的话，再看tm_minute是不是在50以上"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "0f6e2fd3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "今天没有python课，嗨嗨嗨\n"
     ]
    }
   ],
   "source": [
    "# 结果\n",
    "import datetime\n",
    "\n",
    "# 星期设定\n",
    "today = time.localtime().tm_wday\n",
    "\n",
    "# 时间范围设定\n",
    "start_time = datetime.datetime.strptime(str(datetime.datetime.now().date())+'14:30', '%Y-%m-%d%H:%M')\n",
    "end_time = datetime.datetime.strptime(str(datetime.datetime.now().date())+'16:50', '%Y-%m-%d%H:%M')\n",
    "\n",
    "# 当前时间\n",
    "now_time = datetime.datetime.now()\n",
    "\n",
    "# 判断条件\n",
    "if today == 2 and now_time > start_time and now_time < end_time:\n",
    "    print(\"python课ing\")\n",
    "else:\n",
    "    print(\"今天没有python课，嗨嗨嗨\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aeb5ea4d",
   "metadata": {},
   "source": [
    "## 2.1 模块--标准库\n",
    "\n",
    "### 标准库是Python开发团队为满足Python用户日常需求而写好的一些模块，可以直接使用： import 模块名称\n",
    "\n",
    "#### 1. sys模块\n",
    "#### 2. os模块\n",
    "#### 3.datetime模块"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "89ba2bd3",
   "metadata": {},
   "source": [
    "## 2.2 模块--开源模块（pypi.org）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "35010f64",
   "metadata": {},
   "source": [
    "## 2.3 自定义模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f8587861",
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "3dfb6d1a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'3.9.12 (main, Apr  4 2022, 05:22:27) [MSC v.1916 64 bit (AMD64)]'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sys.version"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "778086c1",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "d88215ca",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'D:\\\\Zzhou\\\\大二上作业\\\\python\\\\week 02'"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "os.getcwd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "4945f9a8",
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "9791facc",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.date(2022, 8, 30)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.today()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "c71bc145",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 认识一下 time 模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "a3cd5bca",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "a62d074d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=8, tm_mday=30, tm_hour=19, tm_min=28, tm_sec=3, tm_wday=1, tm_yday=242, tm_isdst=0)"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "2f988743",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1661858903.1427803"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.time() # 时间戳"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "c5009ad8",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "52.69720100909169"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.time()/60/60/24/365"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "da90a6b7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1970"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "2022-52"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "d3b89fd6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=8, tm_mday=30, tm_hour=11, tm_min=29, tm_sec=29, tm_wday=1, tm_yday=242, tm_isdst=0)"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.gmtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "5141e7ea",
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'apple'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
      "Input \u001b[1;32mIn [18]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mapple\u001b[39;00m\n",
      "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'apple'"
     ]
    }
   ],
   "source": [
    "import apple"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "74db329f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Tue Sep 13 16:17:51 2022'"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.asctime(time.localtime())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c7ad3c6e",
   "metadata": {},
   "source": [
    "## 3. 赋值"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7aeb35ed",
   "metadata": {},
   "source": [
    "## 4. 变量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "becde6ad",
   "metadata": {},
   "outputs": [],
   "source": [
    "wait_time = 26\n",
    "WaitTime = 34\n",
    "gf_of_liu = \"Lucy\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "19d5b8f6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "int"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(wait_time)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "d19e01d3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "str"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(gf_of_liu)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "eb66866b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "26"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wait_time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "989fe23c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "34"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "WaitTime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "24c32c45",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Lucy'"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gf_of_liu"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cc27391b",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
